package ui.frame.dialog.panel;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingConstants;

import ui.frame.dialog.DialogConstants;

import static constants.GTextbookConstants.*;

public class TextFieldPanel extends JPanel{

	public TextFieldPanel(int whichField, String englishName, String chineseName, int language){
		if(whichField == DialogConstants.Password){
			textField = new JPasswordField(75);
		}else{
			textField = new CompletableJTextField(75, whichField);
		}
		//set the look of components
        if(language == English){
        	label = new JLabel(englishName,SwingConstants.RIGHT);
        	label.setFont(Label_English_Font);
        	label.setPreferredSize(Label_English_Dimension);
        	textField.setFont(Input_English_Font);
        	textField.setColumns(Text_Field_Columns);
        }
        if(language == Chinese){
        	label = new JLabel(chineseName,SwingConstants.RIGHT);
        	label.setFont(Label_Chinese_Font);
        	label.setPreferredSize(Label_Chinese_Dimension);
        	textField.setFont(Input_Chinese_Font);
        	textField.setColumns(Text_Field_Columns);
        }
		add(label);		
		add(textField);
	}
	public TextFieldPanel(String englishName, String chineseName, int language){
		textField = new JTextField(75);
		//set the look of components
        if(language == English){
        	label = new JLabel(englishName,SwingConstants.RIGHT);
        	label.setFont(Label_English_Font);
        	label.setPreferredSize(Label_English_Dimension);
        	textField.setFont(Input_English_Font);
        	textField.setColumns(20);
        }
        if(language == Chinese){
        	label = new JLabel(chineseName,SwingConstants.RIGHT);
        	label.setFont(Label_Chinese_Font);
        	label.setPreferredSize(Label_Chinese_Dimension);
        	textField.setFont(Input_Chinese_Font);
        	textField.setColumns(20);
        }
		add(label);		
		add(textField);
	}

	public JLabel getLabel() {
		return label;
	}
	public void setLabel(JLabel label) {
		this.label = label;
	}
	
	public JTextField getTextField() {
		return textField;
	}
	public void setTextField(CompletableJTextField textField) {
		this.textField = textField;
	} 
	
	private JLabel label;
	private JTextField textField; 

}
